#define  _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    vector<int> decrypt(vector<int>& code, int k) {
        int n = code.size();
        vector<int> ret(n, 0);
        if (k == 0) return ret;

        int start = 1;
        if (k < 0)
        {
            start = n + k;
            k = -k;
        }

        int cur = 0;
        for (int i = start; i < k + start - 1; i++)
            cur += code[i % n];

        for (int i = 0; i < n; i++)
        {
            cur += code[(start + k - 1 + i) % n];
            ret[i] = cur;
            cur -= code[(start + i) % n];
        }
        return ret;
    }
};
